package brands

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"device_srv/deviceclient"

	"github.com/zeromicro/go-zero/core/logx"
)

// @Summary 品牌信息添加
// @Description 用户通过身份验证才可进行添加
// @Tags 添加
// @Accept json
// @Produce json
// @Param data body types.SendSmsReques true "id"
// @Success 200 {object} types.Response
// @Failure 400 {string} types.Response
// @Failure 500 {string} types.Response
// @Router /brands/brandsAdd [post]
type BrandsAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewBrandsAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BrandsAddLogic {
	return &BrandsAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// BrandsAdd 品牌添加
func (l *BrandsAddLogic) BrandsAdd(req *types.BrandsAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.DeviceRpc.BrandsAdd(l.ctx, &deviceclient.BrandsAddRequest{
		BrandName:        req.BrandName,
		BrandDescription: req.BrandDescription,
	})
	if err != nil {
		return respons.Error(400, "添加失败", err.Error()), err
	}
	return respons.Success(add), nil
}
